package math

import (
	"JVM/Jvmgo/GoToJVM/instructions/base"
	"JVM/Jvmgo/GoToJVM/runtimeData"
)

/*
	这里是进行数学 + 运算
*/

type IADD struct {
	base.NoOperandsInstruction
}
type LADD struct {
	base.NoOperandsInstruction
}
type FADD struct {
	base.NoOperandsInstruction
}
type DADD struct {
	base.NoOperandsInstruction
}

func (self IADD) Execute(frame *runtimeData.Frame) {
	stack := frame.OperandStack()
	val1 := stack.PopInt()
	val2 := stack.PopInt()
	res := val1 + val2
	stack.PushInt(res)
}
func (self LADD) Execute(frame *runtimeData.Frame) {
	stack := frame.OperandStack()
	val1 := stack.PopLong()
	val2 := stack.PopLong()
	res := val1 + val2
	stack.PushLong(res)
}
func (self FADD) Execute(frame *runtimeData.Frame) {
	stack := frame.OperandStack()
	val1 := stack.PopFloat()
	val2 := stack.PopFloat()
	res := val1 + val2
	stack.PushFloat(res)
}
func (self DADD) Execute(frame *runtimeData.Frame) {
	stack := frame.OperandStack()
	val1 := stack.PopDouble()
	val2 := stack.PopDouble()
	res := val1 + val2
	stack.PushDouble(res)
}
